package com.example.chongwushangcheng.ui.pet;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.example.petshopping.R;
import com.example.chongwushangcheng.ui.aquarium.AquariumActivity;
import com.example.chongwushangcheng.ui.main.MainActivity;
import com.google.android.material.tabs.TabLayout;

public class PetActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pet);
        
        // 设置页面间导航
        setupNavigation();
        
        // 选中宠物标签
        TabLayout navMenu = findViewById(R.id.nav_menu);
        navMenu.getTabAt(1).select();
    }
    
    private void setupNavigation() {
        TabLayout navMenu = findViewById(R.id.nav_menu);
        navMenu.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                // 避免重复跳转
                if (tab.getPosition() == 1) return;
                
                switch (tab.getPosition()) {
                    case 0: // 首页 · AI
                        // 跳转到首页
                        Intent mainIntent = new Intent(PetActivity.this, MainActivity.class);
                        startActivity(mainIntent);
                        break;
                    case 2: // 水族
                        // 跳转到水族页面
                        Intent aquariumIntent = new Intent(PetActivity.this, AquariumActivity.class);
                        startActivity(aquariumIntent);
                        break;
                    // 其他标签页的跳转逻辑可以在这里添加
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                // 不需要处理
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
                // 不需要处理
            }
        });
    }
} 